module Kaomoji
  @@kaomo = nil
  
  def self.load(config = 'ime_stdl_utf8.yml')
    @@kaomo ||= YAML.load_file("#{RAILS_ROOT}/config/#{config}").freeze
    printf("=> kaomoji loaded: #{config}, #{@@kaomo.size} loaded\n")
  end 
  
  def self.apply(string_to_filter) 
    output = string_to_filter
    
    if string_to_filter.match(%r{\[.+\]})
	    @@kaomo.each(){ |key,value|
	      output = output.gsub("[#{key}]", value)
	    }
    end
    
    output
  end
end